﻿package app.view.components.sections.children 
{
	import app.model.types.SectionType;
	import app.model.vo.SectionVO;
	import app.view.components.buttons.GlamurBtnBase;
	import app.view.components.sections.LabeledSectionBase;
	import app.view.events.UIEvent;
	import flash.events.MouseEvent;
	
	/**
	 * 2.1 КОНКУРС ДЕТСКОГО РИСУНКА
	 * firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class ChildrenCompetitionMBase extends LabeledSectionBase
	{
		// app.view.components.sections.children.ChildrenCompetitionMBase
		public var childrenCompetitionStageBtn:GlamurBtnBase;
		public var childrenCompetitionWinersBtn:GlamurBtnBase;
		public var childrenInterviewWinersBtn:GlamurBtnBase;
		
		public function ChildrenCompetitionMBase() 
		{
			
		}
		
		private function setEvents():void
		{
			childrenCompetitionStageBtn.addEventListener(MouseEvent.MOUSE_DOWN, onCLickCompetitionStage);
			childrenCompetitionWinersBtn.addEventListener(MouseEvent.MOUSE_DOWN, onCLickCompetitionWiners);
			childrenInterviewWinersBtn.addEventListener(MouseEvent.MOUSE_DOWN, onCLickInterviewWiners);
			
		}
		
		
		private function removeEvents():void
		{
			childrenCompetitionStageBtn.removeEventListener(MouseEvent.MOUSE_DOWN, onCLickCompetitionStage);
			childrenCompetitionWinersBtn.removeEventListener(MouseEvent.MOUSE_DOWN, onCLickCompetitionWiners);
			childrenInterviewWinersBtn.removeEventListener(MouseEvent.MOUSE_DOWN, onCLickInterviewWiners);
			
		}
		
		override public function onDestroy():void 
		{
			// чистим что тут есть и вызываем супера
			removeEvents();
			childrenCompetitionStageBtn.destroy();
			childrenCompetitionWinersBtn.destroy();
			childrenInterviewWinersBtn.destroy();
			
			
			super.onDestroy();
		};
		
		override public function get data():Object { return _data; };
		
		override public function set data(value:Object):void 
		{
			super.data = value;
			
			////trace('data!!!',_data.data);
			
			childrenCompetitionStageBtn.setLang(data.lang);
			childrenCompetitionWinersBtn.setLang(data.lang);
			childrenInterviewWinersBtn.setLang(data.lang);
			
			setEvents();
		};
		
		/**
		 * переход этапы проведения конкурса
		 * @param	e
		 */
		private function onCLickCompetitionStage(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_CHILDREN_COMPETITION_STAGES;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		/**
		 * переход победители
		 * @param	e
		 */
		private function onCLickCompetitionWiners(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_CHILDREN_COMPETITION_WINERS;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		/**
		 * переход интервью победителей
		 * @param	e
		 */
		private function onCLickInterviewWiners(e:MouseEvent):void 
		{
			removeEvents();
			
			var obj:SectionVO = new SectionVO();
			obj.id = SectionType.PAGE_CHILDREN_INTERVIEW_WINERS;
			obj.currentId = id;
			obj.params = null;
			
			var ev:UIEvent = new UIEvent(UIEvent.SECTION_CHANGE);
			ev.data = obj;
			dispatchEvent(ev);
		}
		
	}

}